﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace iNet.Media.Xmp.MicrosoftPhoto
{
	public class RegionInfoXmpPropertyValue : StructureXmpPropertyValue
	{
		#region 欄位
		public static readonly XmpSchema DefaultSchema = new XmpSchema("MPRI", "http://ns.microsoft.com/photo/1.2/t/RegionInfo#");
		#endregion
		#region 建構子
		public RegionInfoXmpPropertyValue()
			: this(DefaultSchema)
		{ }
		public RegionInfoXmpPropertyValue(XmpSchema schema)
			: base(schema)
		{
			if (schema == null)
				throw new ArgumentNullException("schema");
		}
		#endregion
		#region CloneCore
		protected override XmpPropertyValue CloneCore()
		{
			RegionInfoXmpPropertyValue value = new RegionInfoXmpPropertyValue(this.Schema);
			this.CopyFieldsTo(value);
			return value;
		}
		#endregion
		#region DateRegionsValid
		public DateXmpPropertyValue DateRegionsValid { get; set; }
		#endregion
		#region FieldNames
		public override string[] FieldNames
		{
			get 
			{
				return new string[]
				{
					"DateRegionsValid",
					"Regions",
				};
			}
		}
		#endregion
		#region GetFieldCore
		protected override XmpPropertyValue GetFieldCore(string name)
		{
			switch (name)
			{
				case "DateRegionsValid":
					return this.DateRegionsValid;
				case "Regions":
					return this.Regions;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
		#region Regions
		public ArrayXmpPropertyValue Regions { get; set; }
		#endregion
		#region SetFieldCore
		protected override void SetFieldCore(string name, XmpPropertyValue value)
		{
			switch (name)
			{
				case "DateRegionsValid":
					if (value == null || value is DateXmpPropertyValue)
						this.DateRegionsValid = (value as DateXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				case "Regions":
					if (value == null || value is ArrayXmpPropertyValue)
						this.Regions = (value as ArrayXmpPropertyValue);
					else
						throw new ArgumentException();
					break;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
	}

	public class RegionInfoXmpPropertyValueFactory : StructureXmpPropertyValueFactory<RegionInfoXmpPropertyValue>
	{
		#region 建構子
		public RegionInfoXmpPropertyValueFactory()
			: base(RegionInfoXmpPropertyValue.DefaultSchema.NamespaceURI, new string[] { "Regions" })
		{ }
		#endregion
		#region CreateValue
		protected override RegionInfoXmpPropertyValue CreateValue(XmpSchema schema)
		{
			return new RegionInfoXmpPropertyValue(schema);
		}
		#endregion
	}
}
